<template>
	<view>
		<view class="room-scorll-item" v-for="(item1,li) in homestayList" :key="li" @click="homestayDetail(item1)">
			<view class="room-scorll-list_img">
				<image :src="item1.thumb" mode="" style="width: 100%;height: 100%;border-radius: 10rpx;" />
				<view class="room-scorll-list_icon" @click="collectBtn(item1)">
					<iconfont :className="item1.is_like ? 'icon-full-love' : 'icon-love'" :size="26"
						:color="item1.is_like ? '#FB5B32' : '#ffffff'"></iconfont>
				</view>
				<view class="room-scorll-list_assess fui-flex">
					<view class="margin-bottom-xs">
						<fui-rate :quantity="1" :current="1" active="#FF9500" :size="12"></fui-rate>
					</view>
					<view class="font_size_12 text-bold">
						{{(+item1.comment_start).toFixed(1)}}分
					</view>
				</view>
			</view>
			<view class="font_size_18 text-bold margin-top-sm">
				{{item1.name}}
			</view>
			<view class="room-scorll-list_txt fui-flex margin-tb-xs font_size_13 color2">
				<view class="txt color4 text-bold"
					:style="{color:item1.lease_type==='整租' ? greColor : yelColor}">
					{{item1.lease_type}}
				</view>
				<view class="txt">{{item1.regionP.name}}</view>
				<view class="txt">{{item1.regionC.name}}</view>
				<view class="txt">{{item1.address}}</view>
			</view>
		
			<view class="font_size_12 margin-tb-xs">
				<text class="color6 text-bold">￥</text>
				<text class="font_size_25 color6 text-bold">{{item1.price}}</text>/{{item1.time_length}}
			</view>
			<view class="room-scorll-list_bor fui-flex">
				<view class="bor_con bor_red" v-for="(item2,index2) in item1.label" :key="index2">
					{{item2.label_name}}
				</view>
			</view>
		</view>
		<hotel-wish :show="showModal" :hotelId="hotelId" @cancel="hideWish" @success="wishSuccess"></hotel-wish>
	</view>
</template>

<script>
	export default {
		name:"homestay-item",
		props:{
			homestayList:{
				type:Array,
				default(){
					return []
				}
			}
		},
		data() {
			return {
				hotelId:0,
				showModal: false,
			};
		},
		methods:{
			// 民宿详情
			homestayDetail(item) {
				let that = this
				that.$Router.push({
					name: "homestayQuerydetail",
					params: {
						hotel_id: item.id
					}
				})
			},
			hideWish(){
				this.showModal = false
			},
			wishSuccess(){
				this.$emit('getHotels', {
					type: 1
				})
			},
			// 酒店详情
			hotelDetail(item) {
				let that = this
				that.$Router.push({
					name: "querydetail",
					params: {
						hotel_id: item.id
					}
				})
			},
			collectBtn(item) {
				let that = this
				that.hotelId = item.id
				console.log('is_like',item.is_like)
				if (!item.is_like) {
					that.showModal = true
				} else {
					that.showModal = false
					that.fui
						.request('/diandi_hotel/wish/delwish', 'POST', {
							hotel_id: item.id,
							room_id: 0, // 酒店固定是0
						}, false)
						.then(res => {
							this.$emit('getHotels', {
								type: 1
							})
						}).catch(res => {
							console.log('错误', res)
							uni.showToast({
								title: res.message,
								icon: 'none'
							})
						})
				}
			},
			//房间列表
			goHotelQuery() {
				let that = this
				that.$Router.push({
					name: 'hotelquery'
				})
			}
		}
	}
</script>


<style lang="scss" scoped>
	.all_btn {
		font-size: 22rpx;
		color: #999999;
	}

	.room-scorll-item {
		margin-top: 32rpx;

		.room-scorll-list_img {
			position: relative;
			width: 100%;
			height: 360rpx;
			border-radius: 10rpx;

			.room-scorll-list_icon {
				position: absolute;
				right: 32rpx;
				top: 32rpx;
			}

			.room-scorll-list_assess {
				position: absolute;
				left: 16rpx;
				bottom: 16rpx;
				padding: 2rpx 12rpx;
				background-color: rgba(255, 255, 255, .8);
				border-radius: 5rpx;
			}
		}

		.room-scorll-list_txt {
			.txt {
				position: relative;
				margin-right: 24rpx;
			}
			
			.txt:not(:first-child)::after {
				content: "";
				position: absolute;
				right: -12rpx;
				top: 50%;
				transform: translateY(-50%);
				width: 1px;
				height: 20rpx;
				background-color: #D1D1D1;
			}

			.txt:last-child::after {
				content: "";
				background-color: transparent;
			}
		}

		.room-scorll-list_bor {
			.bor_con {
				padding: 4rpx 12rpx;
				font-size: 20rpx;
				border-radius: 5rpx;
				margin-right: 10rpx;
				font-size: 24rpx;

			}

			.bor_red {
				background-color: #FFEEEA;
				color: #FB5B32;
			}

			.bor_gray {
				background-color: #F9F9F9;
				color: #999999;
			}
		}
	}
</style>